import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.Iterator;
import java.util.Vector;
import java.util.Collection;

class VectorMapGeneric<K, V> implements Map<K, V>
{
    static class Entry<K, V> implements Map.Entry<K, V>
    {
        Entry(K key, V value)
        {
            this.key = key;
            this.value = value;
        }
        
        public String toString()
        {
            return "[" + key.toString() + ": " + value.toString() + "]";
        }
        
        public V setValue(V value)
        {
            this.value = value;
            return this.value;
        }

        public V getValue()
        {
            return value;
        }

        public K getKey()
        {
            return key;
        }

        K key;
        V value;
    }
    
    public void clear()
    {
        v.clear();
    }
    
    public boolean containsKey(Object key)
    {
        Entry<K,V> entry = getEntry(key);
        if (entry != null)
        {
            return true;
        }
        return false;
    }
    
    public boolean containsValue(Object value)
    {
        for (Iterator iter = v.iterator(); iter.hasNext(); )
        {
            Entry<K, V> entry = (Entry<K, V>)iter.next();
            if (entry.value.equals(value))
            {
                return true;
            }
        }
        
        return false;
    }
    
    public Set<Map.Entry<K, V>> entrySet()
    {
        Set<Map.Entry<K, V>> result = new TreeSet<Map.Entry<K, V>>();
        for (Iterator<Entry<K, V>> iter = v.iterator(); iter.hasNext(); )
        {
            Entry<K, V> entry = iter.next();
            result.add(entry);
        }
        return result;
    }

    public boolean equals(Object o)
    {
        return v.equals(o);
    }
    
    private Entry<K, V> getEntry(Object key)
    {
        for (Iterator<Entry<K, V>> iter = v.iterator(); iter.hasNext(); )
        {
            Entry<K, V> entry = iter.next();
            if (entry.key.equals(key))
            {
                return entry;
            }
        }
        
        return null;
    }


    public V get(Object key)
    {
        Entry<K, V> entry = getEntry(key);
        if (entry != null)
        {
            return entry.value;
        }
        return null;
    }

    public int hashCode()
    {
        return v.hashCode();
    }
    
    public boolean isEmpty()
    {
        return v.isEmpty();
    }

    public Set<K> keySet()
    {
        Set<K> result = new TreeSet<K>();
        for (Iterator<Entry<K, V>> iter = v.iterator(); iter.hasNext(); )
        {
            Entry<K, V> entry = iter.next();
            result.add(entry.key);
        }
        return result;
    }
    
    public V put(K key, V value)
    {
        Entry<K, V> entry = getEntry(key);
        if (entry != null)
        {
            entry.value = value;
        }
        else
        {
            entry = new Entry<K, V>(key, value);
            v.add(entry);
        }
        return entry.value;
    }

    public void putAll(Map m) {}
    public V remove(Object key) {return null;}
    
    public int size()
    {
        return v.size();
    }

    public Collection<V> values()
    {
        Vector<V> result = new Vector<V>();
        for (Iterator<Entry<K, V>> iter = v.iterator(); iter.hasNext(); )
        {
            Entry<K, V> entry = iter.next();
            result.add(entry.value);
        }
        return result;
    }

    public String toString()
    {
        String s = "{";
        for (Iterator<Entry<K, V>> iter = v.iterator(); iter.hasNext(); )
        {
            Entry<K, V> entry = iter.next();
            s += entry.toString();
            if (iter.hasNext())
            {
                s += ",";
            }
        }
        s = s + "}";
        return s;
    }

    private Vector<Entry<K, V>> v = new Vector<Entry<K, V>>();
}
